Skip to content

Remove example of small-caps font#183

Open
dstansby wants to merge 8 commits intomatplotlib:mainfrom
dstansby:rm-smallcaps
Open

Remove example of small-caps font#183
dstansby wants to merge 8 commits intomatplotlib:mainfrom
dstansby:rm-smallcaps

Conversation

@dstansby
Copy link
Copy Markdown
Member

For a while downloading the font for this example has been failing. I then realised that the code here isn't actually using Matplotlib to specifcially request a small caps font, it's just plotting in a font that is already small caps:

ax.text(1, y, text, size=9, va="center", font=pathlib.Path(file).resolve())

Some brief searching suggests small caps fonts are rare, and thus I think this is a niche enough case that dropping this is okay.

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error is on gitter link. Should we remove this completely now that we are primarily on discourse?

@dstansby

This comment was marked as duplicate.

@dstansby
Copy link
Copy Markdown
Member Author

Error is on gitter link. Should we remove this completely now that we are primarily on discourse?

I tried to fix it, but to no avail. Since it's so low traffic, I think 👍 for removing it, which I've done hte lastest commit.

@dstansby
Copy link
Copy Markdown
Member Author

🎉 this is working now - @timhoffm do you want to do a check on the final state of this PR, then merge if it looks good?

@dstansby
Copy link
Copy Markdown
Member Author

I've manually checked the diffs and they look fine/as expected.

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Mar 31, 2026

Can we download it off Google Fonts, like the others? We should be getting proper small-caps support in 3.11 (i.e., pick a font and toggle the OpenType feature if it supports it.)

@dstansby
Copy link
Copy Markdown
Member Author

Google fonts only serves .ttf files for Garamond (see tree below), which I think would not support small caps?
Given that even in the Matplotlib example the small caps example isn't actually small caps, I'd be tempted to remove for now, and put back in 3.11 if someone can provide working code that is actually using the variant= keyword in Matplotlib.

% tree /Users/dstansby/Downloads/EB_Garamond 
/Users/dstansby/Downloads/EB_Garamond
├── EBGaramond-Italic-VariableFont_wght.ttf
├── EBGaramond-VariableFont_wght.ttf
├── OFL.txt
├── README.txt
└── static
    ├── EBGaramond-Bold.ttf
    ├── EBGaramond-BoldItalic.ttf
    ├── EBGaramond-ExtraBold.ttf
    ├── EBGaramond-ExtraBoldItalic.ttf
    ├── EBGaramond-Italic.ttf
    ├── EBGaramond-Medium.ttf
    ├── EBGaramond-MediumItalic.ttf
    ├── EBGaramond-Regular.ttf
    ├── EBGaramond-SemiBold.ttf
    └── EBGaramond-SemiBoldItalic.ttf

@dstansby
Copy link
Copy Markdown
Member Author

I'm also very up for replacing this with another font that supports small-caps, but I couldn't easily find another one.

@dstansby dstansby requested a review from QuLogic April 2, 2026 09:09
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Apr 7, 2026

I didn't know about that variant option, but this does work with the font features options. On the text-overhaul branch, extending the What's New? example for font features:

from pathlib import Path
import matplotlib.pyplot as plt

font_path = Path.home() / 'Downloads/EBGaramond-VariableFont_wght.ttf'

fig = plt.figure(figsize=(7, 5))

fig.text(0.5, 0.90, 'Ligatures', font=font_path, fontsize=40,
         horizontalalignment='center')
# Default has Standard Ligatures (liga).
fig.text(0, 0.78, 'Default: fi ffi fl st', font=font_path, fontsize=40)
# Disable Standard Ligatures with -liga.
fig.text(0, 0.67, 'Disabled: fi ffi fl st', font=font_path, fontsize=40,
         fontfeatures=['-liga'])
# Enable Discretionary Ligatures with dlig.
fig.text(0, 0.56, 'Discretionary: fi ffi fl st', font=font_path, fontsize=40,
         fontfeatures=['dlig'])

fig.text(0.5, 0.40, 'Capitals', font=font_path, fontsize=40,
         horizontalalignment='center')
# Enable Small Capitals from Capitals.
fig.text(0, 0.28, 'SMALL CAPS FROM CAPS', font=font_path, fontsize=40,
         fontfeatures=['c2sc'])
# Enable Small Caps.
fig.text(0, 0.16, 'Small Caps: AaBbCcDdEeFf', font=font_path, fontsize=40,
         fontfeatures=['smcp'])
# Enable Petite Caps.
fig.text(0, 0.04, 'Petite Caps: AaBbCcDdEeFf', font=font_path, fontsize=40,
         fontfeatures=['pcap'])

plt.show()
ebgaramond

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants